<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>狂耳的作业</title>
</head>
<body>
    <pre>
    <script>
        function lTrim(str, ch) {
            ch = ch || " ";
            if (str[0] == ch) {
                str = str.substr(1);
                return lTrim(str, ch);
            }
            else {
                return str;
            }
        }

        function rTrim(str, ch) {
            ch = ch || " ";
            if (str[str.length - 1] == ch) {
                str = str.substr(0, str.length - 1);
                return rTrim(str, ch);
            }
            else {
                return str;
            }
        }

        function Trim(str, ch) {
            return lTrim(rTrim(str, ch), ch);
        }

        document.writeln(Trim("    hello world       "));
    </script>
    </pre>
</body>
</html>
